package com.wyp168.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Generate
 * @Description TODO
 * @Author wyp168
 * @Date 2022/6/23 20:29
 */
public class Generate {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        System.out.println(generate(5));

    }

    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> result = new ArrayList();
        List<Integer> row = new ArrayList<>();
        for (int i = 0; i < numRows; i ++) {
            row.add(0,1);
            for (int j = 1 ; j < row.size() - 1 ; j ++) {
                row.set(j,row.get(j) + row.get(j + 1));
            }
            result.add(new ArrayList<>(row));
        }

        return result;
    }
}
